
package com.eling.elcms.travel.service.impl;

import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.core.service.impl.GenericManagerImpl;
import com.eling.elcms.core.util.PropertyUtils;
import com.eling.elcms.travel.dao.IReturnCredentialsDao;
import com.eling.elcms.travel.model.FlowStatus;
import com.eling.elcms.travel.model.ReturnCredentials;
import com.eling.elcms.travel.model.SendMsgTpye;
import com.eling.elcms.travel.model.view.ReturnCredentialsView;
import com.eling.elcms.travel.service.IApprovalService;
import com.eling.elcms.travel.service.ICallbackService;
import com.eling.elcms.travel.service.IReturnCredentialsManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ReturnCredentialsManagerImpl extends GenericManagerImpl<ReturnCredentials, Long> implements IReturnCredentialsManager,ICallbackService{
	IReturnCredentialsDao returnCredentialsDao;
	@Autowired
	private IApprovalService approvalService;
	@Autowired
	public void setAllianceOrgDao(IReturnCredentialsDao returnCredentialsDao) {
		this.dao = returnCredentialsDao;
		this.returnCredentialsDao = returnCredentialsDao;
	}

	@Override
	public ReturnCredentials Commit(ReturnCredentials cond) {
		ReturnCredentials model = approvalService.commit("ReturnCredentials", cond);
		Long pkReturnCredentials = PropertyUtils.getProperty(model, "pkReturnCredentials");
		ReturnCredentials returns = returnCredentialsDao.get(pkReturnCredentials);
		returns.setFlowStatus(FlowStatus.Approvaling);
		returns = returnCredentialsDao.save(returns);
		return returns;
	}

	@Override
	public List<ReturnCredentialsView> exitQuery(String status) {
		
		return returnCredentialsDao.exitQuery(status);
	}

	@Override
	public <T extends BaseModel> T setFlowStatus(T model, FlowStatus flowstatus) {
		PropertyUtils.setProperty(model, "flowStatus", flowstatus);
		return model;
	}


	@Override
	public String getMsgTitle(BaseModel model,SendMsgTpye pass) {
//		MemberShipContractFeesRefund mscf =(MemberShipContractFeesRefund) model;
//		String title = "您好，会籍卡号为"+mscf.getMemberShipContractFees().getMemberShipContract().getMembershipCard().getName()+"申请了会籍卡费退款";
//		if (pass ==SendMsgTpye.Procsss ){
//			title += "，请您尽快审批！";
//		}else if(pass  ==SendMsgTpye.Passed){
//			title += "，已通过！";
//		}else if(pass  ==SendMsgTpye.NotPassed){
//			title += "，未通过！";
//		}
//		return title;
		return null;
	}

	
}

